package gjw.jimven.tests;

import android.os.Bundle;
import android.view.View;

import com.bigkoo.convenientbanner.ConvenientBanner;
import com.bigkoo.convenientbanner.holder.CBViewHolderCreator;
import com.nostra13.universalimageloader.core.ImageLoader;
import com.nostra13.universalimageloader.core.ImageLoaderConfiguration;

import java.util.Arrays;
import java.util.List;

import butterknife.ButterKnife;
import gjw.jimven.R;
import gjw.jimven.base.BaseActivity;
import gjw.jimven.utils.TostUtils;

/**
 * @创建者 Jimven
 * @创建时间 2017/8/22/0022  14:09
 */
public class Test01Activity extends BaseActivity implements View.OnClickListener{

    private List<String>     networkImages;
    private String[] images = {"http://img2.imgtn.bdimg.com/it/u=3093785514,1341050958&fm=21&gp=0.jpg",
            "http://img2.3lian.com/2014/f2/37/d/40.jpg",
            "http://d.3987.com/sqmy_131219/001.jpg",
            "http://img2.3lian.com/2014/f2/37/d/39.jpg",
            "http://www.8kmm.com/UploadFiles/2012/8/201208140920132659.jpg",
            "http://f.hiphotos.baidu.com/image/h%3D200/sign=1478eb74d5a20cf45990f9df460b4b0c/d058ccbf6c81800a5422e5fdb43533fa838b4779.jpg",
            "http://f.hiphotos.baidu.com/image/pic/item/09fa513d269759ee50f1971ab6fb43166c22dfba.jpg"
    };
    protected ImageLoader imageLoader;
    private ConvenientBanner mConvenientBanner;

    @Override
    protected int setLayoutId() {
        return R.layout.activity_test01;
    }

    @Override
    protected void setUpView() {
        initView();
        initListener();
        initData();
        initEvent();

    }

    private void initListener() {

    }

    private void initView() {
        mConvenientBanner = (ConvenientBanner) findViewById(R.id.convenientBanner);

    }

    private void initData() {
        imageLoader = ImageLoader.getInstance();
        imageLoader.init(ImageLoaderConfiguration.createDefault(this));
        networkImages = Arrays.asList(images);


    }

    private void initEvent() {

        mConvenientBanner.setPages(new CBViewHolderCreator<NetworkImageHolderView>() {
            @Override
            public NetworkImageHolderView createHolder() {
                return new NetworkImageHolderView();
            }
        },networkImages)
                //设置指示器是否可见
                .setPointViewVisible(true)
                //设置自动切换（同时设置了切换时间间隔）
                .startTurning(2000)
                //设置两个点图片作为翻页指示器，不设置则没有指示器，可以根据自己需求自行配合自己的指示器,不需要圆点指示器可用不设
                //设置指示器的方向（左、中、右）
                .setPageIndicatorAlign(ConvenientBanner.PageIndicatorAlign.ALIGN_PARENT_RIGHT)
                //设置点击监听事件
                //设置手动影响（设置了该项无法手动切换）
                .setManualPageable(true);
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        // TODO: add setContentView(...) invocation
        ButterKnife.bind(this);
    }

    @Override
    public void onClick(View view) {
        TostUtils.showShort(mContext,"哈哈");
    }
}
